package com.example.administrator.myapplication.Util;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by Administrator on 2020/12/7.
 */

public class SpSave {

    //保存数据
    public static boolean saveString(Context context, String key, String value) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("data", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString(key, value);
        editor.commit();
        return true;
    }

    //获取数据
    public static String getSaveString(Context context, String key) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("data", Context.MODE_PRIVATE);
        String value = sharedPreferences.getString(key, "暂无数据");
        return value;
    }
}
